package com.bawei.user

import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class UserTypeAdapter: BaseQuickAdapter<String,BaseViewHolder>(R.layout.item_type) {
    var selectType="全部"
    override fun convert(helper: BaseViewHolder, item: String) {
        helper.setText(R.id.user_title,item)
        val view = helper.getView<TextView>(R.id.user_title)
        if (item==selectType){
            view.setBackgroundResource(R.drawable.shape_text1)
            helper.setTextColor(R.id.user_title,Color.WHITE)
        }else{
            view.setBackgroundResource(R.drawable.shape_text2)
            helper.setTextColor(R.id.user_title,Color.GRAY)
        }
    }
    fun setType(name:String,startIndex:Int,endIndex:Int){
        selectType=name
        notifyItemChanged(startIndex)
        notifyItemChanged(endIndex)
    }
}